async function log_in() {
    const askele = document.getElementById("notes-entry-div");
    const loadele = document.getElementById("notes-loading");
    const resultele = document.getElementById("notes-msg");
    const ent = document.getElementById("notes-entry");
    let uname = ent.value.trim(); // 去除输入的空格

    askele.style.display = "none";
    loadele.style.display = "block";

    const messages = {
        "WMQ": "欢迎回来",
        "YYT": "你知道吗？我今天听广播剧时，听到了“这个组织一直在研究动物的返祖现象”……<br>还有，你知道怎么修复我网页里的BUG吗？找茬一下，谢谢！",
        "WHZ": "你知道吗？编写网页需要学3种语言：HTML，CSS，JavaScript。其中这个登录功能，你猜猜使用哪种写的呢？答案在下面！<br><span class='smallText' style='transform: rotate(180deg);'>（悄悄告诉你，三种都要用）</span>",
        "WHY": "<del>刀割！</del>汪汪队大队长！你最近怎么样啊？"
    };

    if (uname in messages) {
        resultele.innerHTML = `<p>${messages[uname]}</p>`;
    } else {
        resultele.innerHTML = "<p>很抱歉，本次暂无你的消息。不过，在寒假期间，我尽量给每个人都搞一个专属消息！</p>";
    }

    const refreshbut = document.getElementById("refreshButton") || document.createElement("button");
    refreshbut.innerHTML = "退出登录";
    refreshbut.id = "refreshButton";
    refreshbut.onclick = function () { 
        resultele.innerHTML = "";
        resultele.style.display = "none";
        askele.style.display = "block";
        loadele.style.display = "none";
        ent.value = ""; 
    };
    resultele.appendChild(refreshbut);

    await waitFor(1.5);
    loadele.style.display = "none";
    resultele.style.display = "block";
}
function keyup_submit(e) {
    if (document.getElementById("notes-entry").focus) {
        let evt = window.event || e;
        if (evt.keyCode == 13) {
            log_in();
        }
    }
}
function waitFor(seconds) {
    return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
function show_wmq() {
    const pwdent = document.getElementById("wmq-entry");
    const pwddiv = document.getElementById("wmq-entry-div");
    const wmqcon = document.getElementById("wmq-content");
    let passwd = pwdent.value.trim();
    if(passwd != "稳如泰山") {
        alert("间谍！哪里跑！不许猜我们的口号！\n哦，如果你只是写错了，欢迎你再试一次。");
    }else{
        pwddiv.style.display = "none";
        wmqcon.style.display = "block";
    }
}
function keyup_submit_wmq(e) {
    if (document.getElementById("wmq-entry").focus) {
        let evt = window.event || e;
        if (evt.keyCode == 13) {
            show_wmq();
        }
    }
}
